<template>
    <div class="background-cover">
      <el-image
        class="logo"
        :src="require('../assets/logo.png')"
        fit="cover">
      </el-image>
      <div class="login-box">
        <div class="login-text">登录</div>
        <div class="login-input-box">
          <div class="login-icon-div">
            <img src="../assets/icon-user.png" class="login-icon">
          </div>
          <div class="login-input">
            <el-select v-model="utype" placeholder="请选择">
              <el-option
                key="0"
                label="管理员"
                :value="0">
              </el-option>
              <el-option
                key="1"
                label="租户"
                :value="1">
              </el-option>
            </el-select>
          </div>
        </div>
        <div class="login-input-box">
          <div class="login-icon-div">
            <img src="../assets/icon-user.png" class="login-icon">
          </div>
          <div class="login-input">
            <el-input v-model="uname" placeholder="用户名"></el-input>
          </div>
        </div>
        <div class="login-input-box">
          <div class="login-icon-div">
            <img src="../assets/icon-pwd.png" class="login-icon">
          </div>
          <div class="login-input">
            <el-input v-model="upwd" placeholder="账号密码" show-password></el-input>
          </div>
        </div>
        <el-button type="primary" style="width: 292px;margin-top: 24px;" @click="toHome">登录</el-button>
        <div style="margin-top: 45px;">
          <el-divider content-position="center">小鹅定制</el-divider>
        </div>
      </div>
    </div>
</template>
<script>
import { mapActions  } from 'vuex';
export default {
  name: "index",
  data() {
    return {
      uname:'',
      upwd:'',
      utype:0
    };
  },
  created() {
  },
  methods: {
    ...mapActions(['login']),
    toHome(){
      var url="manager/login_ma";
      var params={
        tell: this.uname,
        pwd: this.upwd,
        type: this.utype
      }
      this.$post(url, params).then((res) => {
        console.log(res)
        if (res.code === 0) {
          const user = { supplierName: res.data.supplierName,supplierId: res.data.supplierId,supplierType: res.data.supplierType};
          this.login(user);
          sessionStorage.setItem('supplierId', res.data.supplierId);
          sessionStorage.setItem('supplierType', res.data.supplierType);
          sessionStorage.setItem('supplierName', res.data.supplierName);
          this.$message({
            message: '登录成功！',
            type: 'success'
          })
          this.$router.push('/');
        } else {
          this.$message.error(res.msg)
        }
      });
    }
  }
}
</script>
<style scoped lang="scss">
  .background-cover {
    width: 100%;
    height: 100vh; /* 你可以根据需要调整高度 */
    background-image: url('@/assets/login.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }
  .logo{
    position: absolute;
    height: 100px;
    width: 100px;
    top: 40px;
    left: 50px;
  }
  .login-box{
    width: 292px;
    position: absolute;
    top: 25%;
    right: 18%;
  }
  .login-text{
    font-size: 20px;
    font-weight: 600;
  } 
  .login-input-box{
    border: 1px #666666 solid;
    height: 38px;
    border-radius: 5px;
    width: 290px;
    margin-top: 24px;
  }
  .login-icon-div{
    float: left;
    height: 38px;
    margin-left: 10px;
  }
  .login-icon{
    height: 16px;
    margin-top: 10px;
  }
  .login-input{
    width: 260px;
    float: left;
  }
  ::v-deep .el-select{
    width: 100%;
  }
  ::v-deep .el-input__inner{
    height: 38px;
    background-color: transparent;
    border: 0;
    outline: none;
    color: #000;
  }
  ::v-deep .el-input__inner::-webkit-input-placeholder {
    color: #000000;
  }

  ::v-deep .el-input__inner::-moz-placeholder {
    color: #000000;
  }

  ::v-deep .el-input__inner:-ms-input-placeholder {
    color: #000000;
  }

</style>